package com.zzgc.modules.param;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.zzgc.common.entity.StudentArchives;
import io.swagger.models.auth.In;
import lombok.Data;
import org.springframework.web.bind.annotation.ExceptionHandler;

import java.util.Comparator;
import java.util.Date;
import java.util.List;

/**
 * 下载学生的档案表格, 以学校为单位
 *
 * @Author:
 * @CreateTime: 2022-12-09  10:20
 * @Description:
 * @Version: 1.0
 */
@Data
public class ExportArchivesTemplate implements Comparator<ExportArchivesTemplate> {
    @ExcelProperty("学校")
    private String schoolName;
    @ExcelProperty("学年")
    private String year;
    @ExcelProperty("年级")
    private String gradeName;
    @ExcelProperty("班级")
    private String className;
    @ExcelProperty("学生数组")
    private List<StudentParamTemplate> students;

    @Override
    public int compare(ExportArchivesTemplate o1, ExportArchivesTemplate o2) {
        String grade1 = o1.getGradeName();
        String grade2 = o2.getGradeName();
        String class1 = o1.getClassName();
        String class2 = o2.getClassName();
        class1 = class1.replaceAll("班", "");
        class2 = class2.replaceAll("班", "");
        grade1 = grade1.replaceAll("一年级", "100");
        grade1 = grade1.replaceAll("二年级", "200");
        grade1 = grade1.replaceAll("三年级", "300");
        grade1 = grade1.replaceAll("四年级", "400");
        grade1 = grade1.replaceAll("五年级", "500");
        grade1 = grade1.replaceAll("六年级", "600");
        grade1 = grade1.replaceAll("七年级", "700");
        grade1 = grade1.replaceAll("八年级", "800");
        grade1 = grade1.replaceAll("九年级", "900");
        grade2 = grade2.replaceAll("一年级", "100");
        grade2 = grade2.replaceAll("二年级", "200");
        grade2 = grade2.replaceAll("三年级", "300");
        grade2 = grade2.replaceAll("四年级", "400");
        grade2 = grade2.replaceAll("五年级", "500");
        grade2 = grade2.replaceAll("六年级", "600");
        grade2 = grade2.replaceAll("七年级", "700");
        grade2 = grade2.replaceAll("八年级", "800");
        grade2 = grade2.replaceAll("九年级", "900");
        return (Integer.parseInt(grade1) + Integer.parseInt(class1)) - (Integer.parseInt(grade2) + Integer.parseInt(class2));
    }
}
